import request from "@/utils/request"
import { HeadersContentType } from "@/utils/request"
/**
 * @description 根据会话id获取消息
 * @returns
 */
export function getMessageList(params) {
  return request({
    url: "/monster-im/message/list",
    method: "get",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    params
  })
}

/**
 * @description 分页获取历史消息
 * @returns
 */
export function getMessagePage(data) {
  return request({
    url: "/monster-im/messages/page",
    method: "post",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    data
  })
}

/**
 * @description 分页文件历史
 * @returns
 */
export function getMessageFilePage(data) {
  return request({
    url: "/monster-im/messages/file/page",
    method: "post",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    data
  })
}

//发送消息
export function messagesSend(data) {
  return request({
    url: "/monster-im/messages/send",
    method: "post",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    data
  })
}
//撤回消息
export function messagesRecall(params) {
  return request({
    url: "/monster-im/messages/recall",
    method: "post",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    params
  })
}

//获取会话列表
export function getRecentChatList(data) {
  return request({
    url: "/monster-im/conversation/list",
    method: "get",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    data
  })
}

//创建会话
export function createChat(data) {
  return request({
    url: "/monster-im/chat",
    method: "post",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    data
  })
}

//修改会话列表 通知 置顶 显示
export function updateChat(data) {
  return request({
    url: "/monster-im/chat",
    method: "put",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    data
  })
}

//修改会话已读 @
export function updateReadChat(data) {
  return request({
    url: "/monster-im/chat/read",
    method: "put",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    data
  })
}

//删除会话
export function deleteChat(id) {
  return request({
    url: `/monster-im/chat/${id}`,
    method: "delete",
    headers: {
      "Content-Type": HeadersContentType.json
    }
  })
}

//群发
export function massSending(data) {
  return request({
    url: "/monster-im/messages/massSending",
    method: "post",
    headers: {
      "Content-Type": HeadersContentType.json
    },
    data
  })
}
